<!DOCTYPE html>
<html>
	<head>
		<title>短信模板设置</title>
		<meta http-equiv="Pragma" CONTENT="no-cache">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="renderer" content="webkit">
		<%include("/common/include.html"){}%>
	</head>
	<script type="text/javascript">
		function btn2(ids){
			$.post("message/updataMessageModel",{"ids":ids},function(result){
				$('#shortModel').datagrid('reload');
			});
		}
		function btn1(ids){
			$.post("message/updataMessageModelStart",{"ids":ids},function(result){
				$('#shortModel').datagrid('reload');
			});
		}
	
		$(document).ready(function () {
			$('#shortModel').datagrid({
				singleSelect: true,
				rownumbers: true, //显示序号
				pagination: true,
				pageSize: 10,
				toolbar: '#tb',
				url:'message/queryModel',
				collapsible: true,
				selectOnCheck:$(this).is(':checked'),
				checkOnSelect:$(this).is(':checked'),
				columns:[[
						{field:'choice',checkbox:true },
				  		{field:'modeltype',title:'模板类型',width:60,align:'center'},
				  		{field:'text',title:'内容',width:100,align:'center'},
				  		{field:'status',title:'使用状态',width:100,align:'center'},
				  		{field:'status1',title:'操作',width:100,align:'center',
							formatter:function(value,row,index){
								if(row.status != null && row.status == "启用"){
									return '<a onclick='+'btn2(\'' + row.ids + '\')'+' class='+'button-edit button-success  l-btn l-btn-small'+'><span class='+'l-btn-left'+'><span  style='+'color:red'+' class='+'l-btn-text'+'>禁用</span></span></a>';
								}else if(row.status = "" || row.status == "禁用"){
									return '<a onclick='+'btn1(\'' + row.ids + '\')'+' class='+'button-edit button-success  l-btn l-btn-small'+'><span class='+'l-btn-left'+'><span  style='+'color:green'+' class='+'l-btn-text'+'>启用</span></span></a>';
								}else{
									return null;
								}
							}},
				]]
			});
		});
		
		function addModel(){
			loadDialog($('#shortModel'),null, '新增模板', 'message/addModel');
		};
		function delectModel(){
			$("#boutProduct").html("");
			var rows = $('#shortModel').datagrid('getChecked');
			for(var i=0;i<rows.length;i++){
				var ids = rows[i].ids;
				$("#boutProduct").append("<input type='hidden' name='shortMessageList["+i+"].ids' value='"+ids+"'/>");
			}
			var url='/message/delectMessageModel';
			var data=$('#messagego').serialize();
			var reData = common_ajax.ajaxFunc(url,data);
			$('#shortModel').datagrid('reload');
		};	
	</script>
	<body class="easyui-layout">
		<form id="messagego">
			<div id="boutProduct" style="display: none;"></div>
		</form>
		<div style="padding:10px">
			<div data-options="region:'center',border: false" style="overflow-x:hidden;">
				<table id="shortModel" ></table>
	    	</div>
		</div>
		<div id="tb" style="padding:5px;height: 30px;">
	    	<a href="#" onclick="addModel()" class="easyui-linkbutton" data-options="iconCls:'icon-add'">添加模板</a>
	    	<a href="#" onclick="delectModel()" class="easyui-linkbutton" data-options="iconCls:'icon-no'">删除模板</a>
	    </div>
	</body>
</html>
